﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace BasicClasses
{
    public class InstituicaoDataSource
    {
        private static InstituicaoContext context = new InstituicaoContext();
        private static string tableName = RoleEnvironment.GetConfigurationSettingValue("InstituicaoTable");

        public static IEnumerable<Instituicao> SelectAll()
        {
            return context.Instituicoes;
        }

        public static void Add(Instituicao instituicao, string partitionKey) //partitionKey == Pais
        {
            instituicao.PartitionKey = partitionKey;
            instituicao.RowKey = Guid.NewGuid().ToString();
            context.AddObject(tableName, instituicao);
            context.SaveChanges();
        }
    }
}
